package com.example.robertluozizhao.framecollectdemo.activity;

import android.os.Bundle;
import androidx.annotation.Nullable;
import com.google.android.material.tabs.TabLayout;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
import androidx.appcompat.app.AppCompatActivity;

import com.example.robertluozizhao.framecollectdemo.R;
import com.example.robertluozizhao.framecollectdemo.adapter.holder.TouchOrScrollFragmentAdapter;
import com.example.robertluozizhao.framecollectdemo.fragment.OneFragment;
import com.example.robertluozizhao.framecollectdemo.fragment.ThreeFragment;
import com.example.robertluozizhao.framecollectdemo.fragment.TwoFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by robert.luozizhao on 2018/3/5.
 */

public class TouchOrScrollTestActivity extends AppCompatActivity {

    @BindView(R.id.tl_touch_or_scroll)
    TabLayout tbTouchOrScroll;
    @BindView(R.id.vp_touch_or_scroll)
    ViewPager vpTouchOrScroll;
    private TouchOrScrollFragmentAdapter mTouchOrScrollFragmentAdapter;
    private List<Fragment> mFragmentList;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_touch_or_scroll);
        ButterKnife.bind(this);
        initData();

    }

    private void initData() {
        setData();
        tbTouchOrScroll.setTabMode(TabLayout.MODE_FIXED);
        mTouchOrScrollFragmentAdapter = new TouchOrScrollFragmentAdapter(getSupportFragmentManager(),mFragmentList, this);
        vpTouchOrScroll.setAdapter(mTouchOrScrollFragmentAdapter);
        tbTouchOrScroll.setupWithViewPager(vpTouchOrScroll);

    }

    private void setData() {
        mFragmentList = new ArrayList<>();
        mFragmentList.add(new OneFragment());
        mFragmentList.add(new TwoFragment());
        mFragmentList.add(new ThreeFragment());
    }

}
